home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
404 Jogos
/
CLJG.iso
/
Aventura
/
FireMan.swf
/
scripts
/
frame_1055
/
PlaceObject2_455_131
/
CLIPACTIONRECORD onClipEvent(enterFrame).as
next >
Wrap
Text File
|
2008-09-12
|
6KB
|
251 lines
onClipEvent(enterFrame){
function hitPlatforms()
{
if(mapa.hitTest(_X - 11,_Y,true) || mapa.hitTest(_X + 11,_Y,true))
{
falling = attack = false;
idle = true;
currenthigh = 0;
landing.start();
j = -15;
while(j <= 15)
{
if(mapa.hitTest(_X - 11,_Y + j,true) && !mapa.hitTest(_X - 11,_Y + j - 1,true) || mapa.hitTest(_X + 11,_Y + j,true) && !mapa.hitTest(_X + 11,_Y + j - 1,true))
{
break;
}
j++;
}
_Y = _Y + j - heroe.vscrollspeed;
j = vertical = 0;
}
return undefined;
}
function roof()
{
var u = techo = false;
if(mapa.hitTest(_X + 7,_Y - 48,true))
{
u = techo = true;
}
return u;
}
function setScale()
{
if(preattack)
{
if(_X <= heroe._x)
{
_xscale = Math.abs(_xscale);
}
else
{
_xscale = -1 * Math.abs(_xscale);
}
}
}
function setSpeed()
{
if(attack)
{
if(_xscale > 0)
{
return SPEED;
}
return -1 * SPEED;
}
}
function wallizq()
{
return mapa.hitTest(_X - 23,_Y - 24,true);
}
function wallder()
{
return mapa.hitTest(_X + 23,_Y - 24,true);
}
function Paredes()
{
if(wallder() && horizontal > 0)
{
horizontal = 0;
wall = true;
}
if(wallizq() && horizontal < 0)
{
horizontal = 0;
wall = true;
}
}
function doexplode()
{
myColor.setTransform(myColorNormal);
this.gotoAndStop("death");
}
function dorespawn()
{
currentdamage = 0;
currenthigh = 0;
hitted = false;
flashing = false;
timerdamage = 0;
death = false;
this.gotoAndStop("standing");
falling = true;
idle = attack = preattack = attacking = jump = rising = false;
horizontal = 0;
vertical = 2;
_X = xi;
_Y = _root.mapa._y - yi - heroe.vscrollspeed;
landing = new Sound();
landing.attachSound("sapolanding");
}
function drawframe()
{
if(idle)
{
this.gotoAndStop("standing");
}
if(attack)
{
this.gotoAndStop("jump");
}
}
xi -= heroe.scrollspeed;
_X = _X - heroe.scrollspeed;
_Y = _Y - heroe.vscrollspeed;
_visible = false;
hitable = this.hitTest(_root.mascara);
if(hitable)
{
_visible = true;
if(this.sprite.hotzone.hitTest(heroe.sprite.hotzone))
{
heroe.damage = 3;
heroe.hitted = true;
}
if(this.sprite.hotzone.hitTest(_parent.shoot1) && hitable)
{
hitted = true;
_root.shoot1.impact = true;
_root.hitted.start();
}
if(timerdamage == 0 && hitted)
{
timerdamage = FLASHTIME;
currentdamage += DAMAGE;
}
if(timerdamage > 0)
{
flashing = true;
timerdamage % 3 != 0 ? myColor.setTransform(myColorNormal) : myColor.setTransform(myColorTransform);
timerdamage--;
}
if(flashing && timerdamage == 0)
{
flashing = false;
myColor.setTransform(myColorNormal);
hitted = false;
}
if(currentdamage >= MAXDAMAGE)
{
myColor.setTransform(myColorTransform);
death = true;
delete landing;
}
if(death)
{
_root.shoot1.impact = false;
rising = falling = false;
doexplode();
}
}
if(!death)
{
if(idle)
{
horizontal = 0;
if(hitable)
{
attack = attacking = false;
idle = false;
preattack = true;
timer = DELAY;
}
}
if(preattack)
{
timer--;
if(!timer)
{
preattack = false;
attack = true;
timer = 3;
}
}
if(attack && !jump)
{
timer--;
if(!timer)
{
jump = true;
}
}
if(jump)
{
horizontal = setSpeed();
vertical = vforce * -1;
rising = true;
jump = false;
}
if(rising)
{
if(roof())
{
falling = true;
rising = false;
}
Paredes();
if(currenthigh < MAXJUMP)
{
if(currenthigh < vforcei)
{
vertical = - Math.abs(vforcei);
}
else
{
vertical = - Math.abs(vforce);
}
currenthigh += Math.abs(vertical);
}
else
{
vertical *= heroe.gravity;
currenthigh += Math.abs(vertical);
if(Math.abs(vertical) < 1)
{
falling = true;
rising = false;
}
}
}
if(falling)
{
Paredes();
hitPlatforms();
vertical = Math.abs(vertical) * heroe.accel;
if(vertical > heroe.MAXVERTICAL)
{
vertical = heroe.MAXVERTICAL;
}
}
_Y = _Y + vertical;
_X = _X + horizontal;
setScale();
drawframe();
}
else if(!_root.mascara.hitTest(xi,yi))
{
dorespawn();
}
}